package a6;

public class FibsAndPrimes2 
{

	public static void main(String[] args) 
	{
		int max= 10000;
		int [] fib = new int[1000];	// is there a way to limit array length to only what you assign?
		for ( int i=1, j=1, n1=0 , n2=1, n3 = 0 ; n3<max ; i++, n1=n2, n2=n3, n3=n2+n1 )  //get the fibs
		{
			fib[i] =n3;
			boolean check=isPrime(fib[i]);
			if(check && fib[i]!=0 && fib[i]!= 1)
			{
				System.out.println(j+ " : " + fib[i]);
				j++;
			}
				
		}
		
	}

	
	
	private static boolean isPrime( int n)		//prime check
	{
		for(int m=2; m<=Math.sqrt(n) ; m++ )		
		{
			if(0==n%m )	
				return false;
		}
		return true;
		
	}
}
